home *** CD-ROM | disk | FTP | other *** search
- ------------------------------------------------------------------------------
- Note: This article extracted from the September '91 issue of Carrier Detect
- Journal. At this time, only part 1 of the series was available; Future
- installments may be read in Carrier Detect Journal.
- ------------------------------------------------------------------------------
-
- * Writing a BBS Door (Part 1)
- Tutorial by Scott M. Baker
-
-
- Doors are programs written for a bulletin board system
- to allow the user to perform other tasks than the bulletin
- board software allows. For example, a door could be
- anything from a bbs lister to a multiplayer simulation
- (such as Galactic Warzone, Yankee Trader, Trade Wars,
- etc). This article will be a tutorial on how to write
- door programs. The programs will be written in Turbo
- Pascal (version 5.5 or 6.0) and will use my DoorDriver
- routines to provide support for RBBS, QuickBBS, Wildcat,
- WWIV, etc.
-
- Right now, we're just going to stick with my
- DoorDriver routines since they are the routines that I am
- most familiar with. In the future, we may explore a C or
- basic door library, or another Pascal library. This
- article is the first in a series about Door Writing. I'm
- not sure yet how many articles we have. If there isn't any
- support for this column, then it'll probably be just two.
- If a lot of response comes in, then we'll continue as long
- as I have time to continue writing.
-
-
-
- REQUIREMENTS
-
- What you'll need:
-
- - Turbo Pascal by Borland. Either version 5.5 or
- 6.0 will do.
-
- - DOORDR40.ZIP. This is my Doordriver support
- package for TP5.5 and TP6.0. It includes async
- support, bbs interfacing, etc. Available from
- my bbs (602-577-3650) as well as several other
- sites.
-
- - A basic understanding of Pascal (specifically
- Turbo Pascal). You don't need to be a Pascal
- wizard or anything, but the more knowledge you
- have, the better.
-
- BASIC ELEMENTS OF A 'DOOR'
-
- Ok, time to get started. First lets talk about the basic
- elements that a door needs.
-
- 1) Async communications support.
-
- The door must be able to talk to the user through the
- communications port. Support has to be provided for
- multiple com ports, locked baud rates, etc. The program
- also must monitor the presence of the CARRIER DETECT modem
- line to make sure the carrier is not dropped while the
- door is in use.
-
- 2) BBS software interfacing.
-
- The door needs to be able to grab the user's name, time
- left, and other associated information from the bbs
- software. Since bbs programs lack standardization, there
- are several different methods that have to be accounted
- for.
-
- 3) Support for ANSI (color) graphics and animation.
-
- Just about every door has ANSI capabilities these days,
- so if you want yours to be seriously considered, you'd
- better have it as well.
-
- Doordriver will handle the first two points for you
- automatically when you call the INITDOORDRIVER procedure
- described below. Doordriver has support for the third
- point (ANSI graphics), but you'll need to use your own
- skills in deciding where you wish to put colors, what
- colors to use, etc.
-
-
- DOORDRIVER PROCEDURES
-
-
- There are a series of procedures that doordriver will
- provide to you for accomplishing these tasks. Without
- getting too complex, let's discuss a few of them:
-
- PROCEDURE INITDOORDRIVER(ctl_file_name: string);
-
- This procedure initializes the door support system, comm
- port, grabs the user name, and a few other necessary
- things. The variable "ctl_file_name" is a string
- containing the name of the control file that your door
- will use. For now, let's just ignore the control file and
- use the sample included with the DD package.
-
- PROCEDURE SWRITE(out_str: string);
-
- This is DD's compliment to the Write() statement of Turbo
- Pascal. The "S" stands for simultaneous. Output will be
- written to both the remote user (through the com port) and
- the local screen. "out_str" is the string containing the
- data you wish to write. Most of your output will use
- either this or the following SWRITELN procedure.
-
- PROCEDURE SWRITELN(out_str: string);
-
- Same as SWRITE, except a carriage return/line feed is
- appended to the end of the string. This is similar to
- TP's writeln statement.
-
- variable USER_FIRST_NAME: STRING;
-
- After INITDOORDRIVER has been called, this variable will
- contain the user's first name. The string will be all
- upper-case.
-
- variable USER_LAST_NAME: STRING;
-
- Similar to USER_FIRST_NAME, this variable will contain the
- user's last name. As with USER_FIRST_NAME, it is only
- valid after the call to INITDOORDRIVER has been made.
-
-
-
- YOUR FIRST DOOR
-
-
- Now that you've seen a few of doordriver's support
- routines, lets put them to work in the "hello door." The
- hello door will be simply a door version of the standard
- hello program. Meaning that it displays "hello world" to
- the screen. First, a note about my code, I'll be placing
- line numbers ({1}, {2}, etc) in the code. These are
- intended for discussion purposes and are not needed in the
- pascal program itself.
-
- HLODOOR.PAS:
-
- {1} Program HelloDoor;
- {2}
- {3} uses crt, doordriv;
- {4}
- {5} begin
- {6} InitDoorDriver('Doordriv.CTL');
- {7} swriteln('Hello World!');
- {8} delay(5000);
- {9} end.
-
- Experienced pascal programmers will feel a bit insulted by
- the simplicity of the above program, but it is a necessary
- step in learning to use door driver.
-
-
- COMPILING AND RUNNING THE DOOR
-
-
- Once you've got that typed in, then it's time to compile
- HLODOOR. Using either Turbo Pascal version 5.5 or version
- 6.0, compile the program to disk. If all goes well, then
- you'll be left with HLODOOR.EXE on your hard drive.
- Doordriv.doc (supplied with doordriver) includes infor-
- mation on how to configure / run the door on your system.
- For now, let's just worry about running the door in local
- mode. For local mode, type "/L" on the command line. For
- example, "HLODOOR /L" will run HLODOOR. Since you are a
- local user, the door will prompt you for your first and
- last name. A remote user's information would be gathered
- from the bbs information file (i.e. DORINFOx.DEF). We
- won't worry about that for now.
-
-
- ANALYSIS OF CODE
-
-
- Now lets go through the important lines of code one by
- one.
-
- LINE 3: Uses crt, DoorDriv;
-
- The "uses" statement is required by Turbo Pascal to tell
- TP which units we will be using. Obviously, we need
- "doordriv" for DD's procedures. "crt" is required because
- we use the DELAY procedure.
-
- LINE 6: InitDoorDriver('DoorDriv.CTL');
-
- This is that all-important initialization statement
- described somewhere above. It tells doordriver to get
- things all set up and working. The 'Doordriv.CTL' is the
- name of that "control file" and we won't pay any attention
- to it for now.
-
- LINE 7: swriteln('Hello World!');
-
- This is our screen output. It'll write "Hello World" to
- both the user and the local screen. Since its SWRITELN
- and not SWRITE, a carriage return and line feed also will
- be sent. There are several ways that this could have been
- done. For example:
-
- {1} swrite('Hello');
- {2} swriteln(' World!');
-
- - - - or - - -
-
- {1} swrite('Hello');
- {2} swrite(' World!');
- {3} swriteln('');
-
- The output will be the same in the above situations.
-
- LINE 8: Delay(5000);
-
- This routine is provided by Borland and will cause our
- program to delay so you can see the "hello world" before
- doordriver exits and clears the screen. The string "Hello
- World!" looks pretty plain, doesn't it? Maybe we should
- put something a bit more impressive in, such as the user's
- name. This would involve using the variables
- USER_FIRST_NAME and USER_LAST_NAME. The modification is
- simple enough:
-
- Change line 7 from:
-
- {7} swriteln('Hello World!');
-
- to:
-
- {7} swriteln('Hello, '+user_first_name+' '+
- user_last_name+'!');
-
- As you may have noticed, I used plus signs (+) instead of
- commas (,) to separate the string parameters in the
- SWRITELN line. With a standard WRITELN statement, you may
- use as many variables as you wish, but with SWRITELN, we
- are limited to 1 string variable. The point is, TP
- requires us to merge our string variables together with
- the plus sign.
-
- CONCLUSION
-
- That's about all the space we have for now. Until our
- next release, play around with the SWRITE and SWRITELN
- procedures and see what neat things you can write to the
- screen. Next time, we'll dive deeper into some inte-
- ractive communication with the user (i.e. we'll ask him
- something and then write in back to the screen) as well as
- play with some more of DD's internal variables.
-
-
- Contents copyright (c) Carrier Detect Journal.